home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 3.2 / Ham Radio Version 3.2 (Chestnut CD-ROMs)(1993).ISO / packet / n17jsrc / netrom.h < prev    next >
Text File  |  1990-12-11  |  7KB  |  222 lines

  1. #ifndef    _NETROM_H
  2. #define    _NETROM_H
  3.  
  4. #ifndef    _MBUF_H
  5. #include "mbuf.h"
  6. #endif
  7.  
  8. #ifndef    _IFACE_H
  9. #include "iface.h"
  10. #endif
  11.  
  12. #ifndef    _AX25_H
  13. #include "ax25.h"
  14. #endif
  15.  
  16. #ifndef _NR4_H
  17. #include "nr4.h"
  18. #endif
  19.  
  20. /* net/rom support definitions
  21.  * Copyright 1989 by Daniel M. Frank, W9NK.  Permission granted for
  22.  * non-commercial distribution only.
  23.  */
  24.  
  25. #define NR3HLEN        15    /* length of a net/rom level 3 hdr, */
  26. #define NR3DLEN        241    /* max data size in net/rom l3 packet */
  27. #define NR3NODESIG    0xff    /* signature for nodes broadcast */
  28. #define NR3NODEHL    7    /* nodes bc header length */
  29.  
  30. #define NRNUMIFACE    10    /* number of interfaces associated */
  31.                 /* with net/rom network layer      */
  32. #define NRNUMCHAINS    17    /* number of chains in the */
  33.                 /* neighbor and route hash tables */
  34. #define NRRTDESTLEN    21    /* length of destination entry in */
  35.                 /* nodes broadcast */
  36. #define NRDESTPERPACK    11    /* maximum number of destinations per */
  37.                 /* nodes packet */
  38.  
  39. /* NET/ROM protocol numbers */
  40. #define NRPROTO_IP    0x0c
  41.  
  42. /* Internal representation of net/rom network layer header */
  43. struct nr3hdr {
  44.     char source[AXALEN] ;    /* callsign of origin node */
  45.     char dest[AXALEN] ;        /* callsign of destination node */
  46.     unsigned ttl ;                /* time-to-live */
  47. } ;
  48.  
  49. /* Internal representation of net/rom routing broadcast destination */
  50. /* entry */
  51. struct nr3dest {
  52.     char dest[AXALEN] ;        /* destination callsign */
  53.     char alias[AXALEN] ;            /* ident, upper case ASCII, blank-filled */
  54.     char neighbor[AXALEN] ;    /* best-quality neighbor */
  55.     unsigned quality ;        /* quality of route for this neighbor */
  56. } ;
  57.  
  58.  
  59. /* net/rom interface table entry */
  60. struct nriface {
  61.     struct iface *iface ;        /* pointer to ax.25 interface */
  62.     char alias[AXALEN] ;        /* alias for this interface's node */
  63.                     /* broadcasts */
  64.     unsigned quality ;        /* net/rom link quality estimate */
  65. } ;
  66.  
  67. /* net/rom neighbor table structure */
  68. struct nrnbr_tab {
  69.     struct nrnbr_tab *next ;    /* doubly linked list pointers */
  70.     struct nrnbr_tab *prev ;
  71.     char call[AXALEN] ;        /* call of neighbor + 2 digis max */
  72.     unsigned iface ;        /* offset of neighbor's port in */
  73.                     /* interface table */
  74.     unsigned refcnt ;        /* how many routes for this neighbor? */
  75. } ;
  76.  
  77. #define    NULLNTAB    (struct nrnbr_tab *)0
  78.  
  79.  
  80. /* A list of these structures is provided for each route table */
  81. /* entry.  They bind a destination to a neighbor node.  If the */
  82. /* list of bindings becomes empty, the route table entry is    */
  83. /* automatically deleted.                                       */
  84.  
  85. struct nr_bind {
  86.     struct nr_bind *next ;        /* doubly linked list */
  87.     struct nr_bind *prev ;
  88.     unsigned quality ;        /* quality estimate */
  89.     unsigned obsocnt ;        /* obsolescence count */
  90.     unsigned flags ;
  91. #define    NRB_PERMANENT    0x01        /* entry never times out */
  92. #define NRB_RECORDED    0x02        /* a "record route" entry */
  93.     struct nrnbr_tab *via ;        /* route goes via this neighbor */
  94. } ;
  95.  
  96. #define    NULLNRBIND    (struct nr_bind *)0
  97.  
  98.  
  99. /* net/rom routing table entry */
  100.  
  101. struct nrroute_tab {
  102.     struct nrroute_tab *next ;    /* doubly linked list pointers */
  103.     struct nrroute_tab *prev ;
  104.     char alias[AXALEN] ;            /* alias of node */
  105.     char call[AXALEN] ;        /* callsign of node */
  106.     unsigned num_routes ;        /* how many routes in bindings list? */
  107.     struct nr_bind *routes ;    /* list of neighbors */
  108.  
  109. } ;
  110.  
  111. #define    NULLNRRTAB    (struct nrroute_tab *)0
  112.  
  113.  
  114. /* The net/rom nodes broadcast filter structure */
  115. struct nrnf_tab {
  116.     struct nrnf_tab *next ;        /* doubly linked list */
  117.     struct nrnf_tab *prev ;
  118.     char neighbor[AXALEN] ;    /* call of neighbor to filter */
  119.     unsigned iface ;        /* filter on this interface */
  120.     unsigned quality;    /* explicit quality of this node */
  121. } ;
  122.  
  123. #define    NULLNRNFTAB    (struct nrnf_tab *)0
  124.  
  125. /* Structure for handling raw NET/ROM user sockets */
  126. struct raw_nr {
  127.     struct raw_nr *prev;
  128.     struct raw_nr *next;
  129.  
  130.     struct mbuf *rcvq;    /* receive queue */
  131.     char protocol;        /* Protocol */
  132. };
  133. #define    NULLRNR    ((struct raw_nr *)0)
  134.  
  135. /* The interface table */
  136. extern struct nriface Nrifaces[NRNUMIFACE] ;
  137.  
  138. /* How many interfaces are in use */
  139. extern unsigned Nr_numiface ;
  140.  
  141. /* The neighbor hash table (hashed on neighbor callsign) */
  142. extern struct nrnbr_tab *Nrnbr_tab[NRNUMCHAINS] ;
  143.  
  144. /* The routes hash table (hashed on destination callsign) */
  145. extern struct nrroute_tab *Nrroute_tab[NRNUMCHAINS] ;
  146.  
  147. /* The nodes broadcast filter table */
  148. extern struct nrnf_tab *Nrnf_tab[NRNUMCHAINS] ;
  149.  
  150. extern char Nr_nodebc[AXALEN];
  151.  
  152. /* filter modes: */
  153. #define    NRNF_NOFILTER    0    /* don't filter */
  154. #define    NRNF_ACCEPT    1    /* accept broadcasts from stations in list */
  155. #define    NRNF_REJECT    2    /* reject broadcasts from stations in list */
  156.  
  157. /* The filter mode */
  158. extern unsigned Nr_nfmode ;
  159.  
  160. /* The time-to-live for net/rom network layer packets */
  161. extern unsigned short Nr_ttl ;
  162.  
  163. /* The obsolescence count initializer */
  164. extern unsigned Obso_init ;
  165.  
  166. /* The threshhold at which routes becoming obsolete are not broadcast */
  167. extern unsigned Obso_minbc ;
  168.  
  169. /* The quality threshhold below which routes in a broadcast will */
  170. /* be ignored */
  171. extern unsigned Nr_autofloor ;
  172.  
  173. /* Whether we want to broadcast the contents of our routing
  174.  * table, or just our own callsign and alias:
  175.  */
  176. extern int Nr_verbose ;
  177.  
  178. /* The maximum number of routes maintained for a destination. */
  179. /* If the list fills up, only the highest quality routes are  */
  180. /* kept.  This limiting is done to avoid possible over-use of */
  181. /* memory for routing tables in closely spaced net/rom networks. */
  182. extern unsigned Nr_maxroutes ;
  183.  
  184. /* The netrom pseudo-interface */
  185. extern struct iface *Nr_iface ;
  186.  
  187. /* Functions */
  188.  
  189. /* In nr3.c: */
  190. void del_rnr __ARGS((struct raw_nr *rpp));
  191. char *find_nralias __ARGS((char *));
  192. struct nrroute_tab *find_nrroute __ARGS((char *));
  193. void nr_bcnodes __ARGS((unsigned ifno));
  194. void nr_nodercv __ARGS((struct iface *iface,char *source,struct mbuf *bp));
  195. int nr_nfadd __ARGS((char *, unsigned, unsigned));
  196. int nr_nfdrop __ARGS((char *, unsigned));
  197. void nr_route __ARGS((struct mbuf *bp,struct ax25_cb *iaxp));
  198. int nr_routeadd __ARGS((char *, char *, unsigned,
  199.     unsigned, char *, unsigned, unsigned));
  200. int nr_routedrop __ARGS((char *, char *, unsigned));
  201. int nr_send __ARGS((struct mbuf *bp,struct iface *iface,int32 gateway,int prec,
  202.     int del,int tput,int rel));
  203. void nr_sendraw __ARGS((char *dest,unsigned family,unsigned proto,
  204.     struct mbuf *data));
  205. void nr3output __ARGS((char *dest,struct mbuf *data));
  206. int16 nrhash __ARGS((char *s));
  207. struct raw_nr *raw_nr __ARGS((char));
  208.  
  209. /* In nrcmd.c: */
  210. void donrdump __ARGS((struct nr4cb *cb));
  211. int doroutedump __ARGS((void));
  212. int dorouteinfo __ARGS((int argc,char *argv[],void *p));
  213. int putalias __ARGS((char *to, char *from,int complain));
  214.  
  215. /* In nrhdr.c: */
  216. struct mbuf *htonnr3 __ARGS((struct nr3hdr *));
  217. struct mbuf *htonnrdest __ARGS((struct nr3dest *));
  218. int ntohnr3 __ARGS((struct nr3hdr *, struct mbuf **));
  219. int ntohnrdest __ARGS((struct nr3dest *ds,struct mbuf **bpp));
  220.  
  221. #endif    /* _NETROM_H */
  222.